package cn.ipanel.bigdata.source.mysql

import cn.ipanel.bigdata.boot.source.genre.Mysql
import cn.ipanel.bigdata.dw.AbsExtProduct
import org.apache.spark.sql.{Dataset, Row}

/**
 * Author: lzz
 * Date: 2021/12/21 17:01
 */
object DTVS_Eit extends Mysql("homed_dtvs", "homed_dtvs") {

  final val STATUS_SHOW       : Int = 0x01 // 1.节目隐藏/显示
  final val STATUS_VALID      : Int = 0x02 // 2.回看是否有效
  final val STATUS_EPG        : Int = 0x03 // 3.回看节目是否被精准EPG矫正过
  final val STATUS_FIRST      : Int = 0x04 // 4.回看节目是否首播
  final val STATUS_ARTIFICIAL : Int = 0x05 // 5.回看节目时间是否被人工确认
  final val STATUS_DEMAND6    : Int = 0x06 // 6.回看节目自动转点播状态（0.未转 1.正在转 2.成功 3.失败）
  final val STATUS_DEMAND7    : Int = 0x07 // 7.回看节目自动转点播状态（0.未转 1.正在转 2.成功 3.失败）
  final val STATUS_ENTER      : Int = 0x08 // 8.回看节目所有信息是否确认

  final val HOMED_NETWORK_ID: String = "homed_network_id"   // homed网络id, 目前全设为1
  final val HOMED_SERVICE_ID: String = "homed_service_id"   // homed频道id, 取值可查看homed_service_id表
  final val EVENT_ID        : String = "event_id"           // 节目id
  final val EVENT_TYPE      : String = "event_type"         // 节目类型
  final val LABELS          : String = "labels"             // 节目类型的标签
  final val LANGUAGE        : String = "language"           // 节目语言
  final val EVENT_NAME      : String = "event_name"         // 节目名称
  final val START_TIME      : String = "start_time"         // 节目开始时间
  final val DURATION        : String = "duration"           // 节目时长
  final val EVENT_TEXT      : String = "event_text"         // 暂时没用
  final val EVENT_EXT_TEXT  : String = "event_ext_text"     // 节目附加信息
  final val RUNNING_STATUS  : String = "running_status"     //
  final val CONTENT_TYPE    : String = "content_type"       //
  final val COMPONENT_ATTR  : String = "component_attr"     //
  final val THUMBNAIL_DIR   : String = "thumbnail_dir"      //
  final val ORIG_START_TIME : String = "orig_start_time"
  final val ORIG_DURATION   : String = "orig_duration"
  final val F_EDIT_TIME     : String = "f_edit_time"
  final val F_CONTENT_TYPE  : String = "f_content_type"
  final val F_SUB_TYPE      : String = "f_sub_type"
  final val F_ABSTRACT      : String = "f_abstract"
  final val F_ACTOR         : String = "f_actor"
  final val F_DIRECTOR      : String = "f_director"
  final val F_COUNTRY       : String = "f_country"
  final val F_PUBLISH_YEAR  : String = "f_publish_year"
  final val F_SCREEN_TIME   : String = "f_screen_time"
  final val F_SCORE         : String = "f_score"
  final val F_RELEVANCE_ID  : String = "f_relevance_id"
  final val F_ASSET_ID      : String = "f_asset_id"
  final val F_DEMAND_TYPE   : String = "f_demand_type"
  final val F_DEMAND_EXTEND : String = "f_demand_extend"
  final val F_HOT_SCORE     : String = "f_hot_score"
  final val F_SECOND_HOT_SCORE: String = "f_second_hot_score"
  final val F_SERIES_ID     : String = "f_series_id"
  final val F_SERIES_INDEX  : String = "f_series_index"
  final val F_ROUND_INFO    : String = "f_round_info"
  final val F_PLAY_URL      : String = "f_play_url"

  override def getTBColumns: Seq[String] = Table.FIELDS
  override def buildTable: String = ""
  override def emptyTable: Dataset[Table] = {
    import IMPLICITS._
    spark.createDataset(spark.sparkContext.emptyRDD[Table])
  }

  class Table(var homed_network_id: String,
               var homed_service_id: Long,
               var event_id: Long,
               var event_type: Int,
               var labels: String,
               var language: String,
               var event_name: String,
               var start_time: Long,
               var duration: Long,
               var event_text: String,
               var event_ext_text: String,
               var running_status: Int,
               var content_type: Int,
               var component_attr: Int,
               var thumbnail_dir: String,
               var orig_start_time: Long,
               var orig_duration: Long,
               var f_edit_time: Long,
               var f_content_type: Int,
               var f_sub_type: String,
               var f_abstract: String,
               var f_actor: String,
               var f_director: String,
               var f_country: String,
               var f_publish_year: String,
               var f_screen_time: String,
               var f_score: Int,
               var f_relevance_id: String,
               var f_asset_id: String,
               var f_demand_type: String,
               var f_demand_extend: String,
               var f_hot_score: Long,
               var f_second_hot_score: Long,
               var f_series_id: Long,
               var f_series_index: String,
               var f_round_info: Int,
               var f_play_url: String) extends AbsExtProduct {
   override def toParam:  Array[Any] = Array(homed_network_id, homed_service_id, event_id, event_type, labels,
                                        language, event_name, start_time, duration, event_text,
                                        event_ext_text, running_status, content_type, component_attr, thumbnail_dir,
                                        orig_start_time, orig_duration, f_edit_time, f_content_type, f_sub_type,
                                        f_abstract, f_actor, f_director, f_country, f_publish_year,
                                        f_screen_time, f_score, f_relevance_id, f_asset_id, f_demand_type,
                                        f_demand_extend, f_hot_score, f_second_hot_score, f_series_id, f_series_index,
                                        f_round_info, f_play_url)
  }

  object Table {

    final lazy val FIELDS = {
      Seq(HOMED_NETWORK_ID, HOMED_SERVICE_ID, EVENT_ID, EVENT_TYPE, LABELS,
          LANGUAGE, EVENT_NAME, START_TIME, DURATION, EVENT_TEXT,
          EVENT_EXT_TEXT, RUNNING_STATUS, CONTENT_TYPE, COMPONENT_ATTR, THUMBNAIL_DIR,
          ORIG_START_TIME, ORIG_DURATION, F_EDIT_TIME, F_CONTENT_TYPE, F_SUB_TYPE,
          F_ABSTRACT, F_ACTOR, F_DIRECTOR, F_COUNTRY, F_PUBLISH_YEAR,
          F_SCREEN_TIME, F_SCORE, F_RELEVANCE_ID, F_ASSET_ID, F_DEMAND_TYPE,
          F_DEMAND_EXTEND, F_HOT_SCORE, F_SECOND_HOT_SCORE, F_SERIES_ID, F_SERIES_INDEX,
          F_ROUND_INFO, F_PLAY_URL)
    }

    def apply(row: Row): Table = create(row)
    def create(row: Row): Table = {
      null
    }
  }
}